(function ($, Handlebars, root) {
    const source = $("#music-info").html();
    let html, template;

    function createHelper() {
        Handlebars.registerHelper("endTime", function (duration) {
            return `${Math.floor(duration / 60) > 10 ? Math.floor(duration / 60) : "0" + Math.floor(duration / 60)}:${duration % 60}`
        })
    }

    function renderBack(src) {
        const img = new Image();
        img.src = src;
        img.onload = () => {
            root.blurImg(img, $(document.body));
        }
    }

    function render(data) {
        template = Handlebars.compile(source);
        html = template(data);
        $(".wrapper").html(html);
        renderBack(data.image);
    }

    createHelper();
    root.render = render;
})(window.jQuery, window.Handlebars, window.player || (window.player = {}))